package com.lvmama.monkey.config

import java.io.{BufferedInputStream, FileInputStream, FileNotFoundException, IOException}
import java.util.Properties

/**
  * Created by hejing on 2017/10/11.
  */
object ConfigHelper {

  def getProperties(path: String): Properties = {
    val properties = new Properties()
    try {
      val filePath =System.getProperty("user.dir")
      val e = new BufferedInputStream(new FileInputStream(filePath+"/"+path))
      //  本地运行时将db-config.properties文件放在resources文件夹下，以下方式直接读取
//      val e = ConfigHelper.getClass.getClassLoader.getResourceAsStream(path)
      properties.load(e)
    } catch {
      case e1: FileNotFoundException => e1.printStackTrace()
      case e2: IOException => e2.printStackTrace()
    }
    properties
  }

}
